-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: update OpenRouter API to support input/output modalities and filter image generation models #7492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lter image generation models - Updated openRouterArchitectureSchema to use input_modalities and output_modalities arrays - Modified parseOpenRouterModel to accept separate inputModality and outputModality parameters - Updated image support detection to use input_modalities array - Added comprehensive filtering to exclude image generation models (models with 'image' in output_modalities) - Applied filtering across all OpenRouter model fetchers: - src/api/providers/fetchers/openrouter.ts - webview-ui/src/components/ui/hooks/useOpenRouterModelProviders.ts - apps/web-roo-code/src/lib/hooks/use-open-router-models.ts - Updated all tests to use new modality format - Added test coverage for filtering functionality This ensures we only show text-based language models and exclude image generation models from model lists.
|
🚀 Preview deployed! Your changes have been deployed to Vercel: Preview URL: https://roo-code-website-8cg9vurtc-roo-code.vercel.app This preview will be updated automatically when you push new commits to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and they properly implement the migration from single modality to separate input_modalities and output_modalities arrays. The filtering of image generation models is consistently applied across all fetchers. I have some suggestions for improvement.
Additional observations:
- There's still a hardcoded
modalities: ["image", "text"]field insrc/api/providers/openrouter.tsline 305 in thegenerateImagemethod that might need updating for consistency - Consider extracting the duplicate filtering logic into a shared utility function for better maintainability
|
|
||
| return result.data.data | ||
| .filter((rawModel) => { | ||
| // Skip image generation models (models that output images) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment here explaining why image generation models are being filtered out. This would help future maintainers understand the business logic behind this decision.
| // Skip image generation models (models that output images) | |
| .filter((rawModel) => { | |
| // Skip image generation models (models that output images) | |
| // We only want text-based language models in the model selection UI | |
| return !rawModel.architecture?.output_modalities?.includes("image") | |
| }) |
| } | ||
|
|
||
| // Model with image output should be filtered out - we only test parseOpenRouterModel | ||
| // since the filtering happens in getOpenRouterModels/getOpenRouterModelEndpoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test coverage for the parseOpenRouterModel function! Since the filtering happens at a higher level in getOpenRouterModels and getOpenRouterModelEndpoints, would it be valuable to add integration tests that verify the filtering behavior actually excludes image generation models from the returned results?
Summary
Updates the OpenRouter integration to support the new API response format with separate input_modalities and output_modalities arrays, replacing the single modality field. Also adds comprehensive filtering to exclude image generation models from all model lists.
Changes
Core Updates
Filtering Implementation
Added filtering across all OpenRouter model fetchers to exclude image generation models (models with 'image' in output_modalities):
Testing
Impact
This ensures users only see relevant text-based language models and not image generation models in the model selection UI.